package com.vayne.producer;

import com.vayne.common.AbstractProducer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.Properties;

public class ProducerDemo extends AbstractProducer {

    // version v0 message test
    private static final String TOPIC = "ms_format_v2";
    private static final String BOOTSTRAP_SERVERS = "localhost:9092";

    public static void main(String[] args) {
        Properties properties = initConfig(BOOTSTRAP_SERVERS);
        try (KafkaProducer<String, String> producer = new KafkaProducer<>(properties)) {
            // send a message with key = key and value = value
            ProducerRecord<String, String> record = new ProducerRecord<>(TOPIC, "key", "value");
            producer.send(record);
            // Future aa = ProducerDemo.sendOne("03", "dd");
            // System.out.println(">>>>>>>>>>: " + aa.get().toString());
            // Thread.sleep(3000);
            // initProducer().send(new ProducerRecord<>(TOPIC, key, value));
            // producer.send(record).get();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
